<template>
  <div class="articleItem-container">
    <div>
      <h1>{{article.title}}</h1>
    </div>
    <div>
      <span style="margin-left:15px">{{article.createTime | parseTimeByString}}</span>
      <span style="margin:0 8px 0 8px">{{articleItem.username}}</span>
      <i class="el-icon-view"></i>
      <span style="margin-left:8px">{{article.visits}}</span>
    </div>
    <div class="content">
      <div v-html="article.articleBody"></div>
    </div>
  </div>
</template>

<script>
// 导入数据请求的方法
import { detail } from '@/api/hmmm/articles.js'
import { parseTimeByString } from "../../filters/index";
export default {
  // 父组件传过来的文章数据
  props: {
    articleItem: {
      type: Object,
      require: true
    }
  },
  data () {
    return {
      article: {}
    }
  },
  created () {
    console.log(this.articleItem)
    this.getArticleItem()
  },
  methods: {
    // 获取文章详情的数据请求
    async getArticleItem () {
      try {
        const { data: res } = await detail(this.articleItem)
        console.log(res)
        this.article = res
      } catch (error) {
        this.$message(error)
      }
    }
  }
}
</script>

<style>
.content {
    border-top:1px dashed rgb(225, 225, 225);
    border-bottom:1px dashed  rgb(225, 225, 225);
    background-color: rgb(245, 245, 245);
    box-sizing: border-box;
    padding: 10px;
    margin-top: 10px;
  }
</style>